import os
import sys
import time
import pymssql

# 将工程目录加入包扫描
currPath = os.path.abspath(os.path.dirname(__file__))
srcPath = os.path.split(currPath)[0]
rootPath = os.path.split(srcPath)[0]
projectPath = os.path.split(rootPath)[0]
sys.path.append(projectPath)

from src.utils.LogUtils import Logger

logger = Logger()


# 计算主体利差
class AbsDataSpread:
    def __init__(self, logger,  absSqlServer):
        self.logger = logger
        self.arg = sys.argv
        self.absSqlServer = absSqlServer


    # 根据信用代码抽取债券利差数据
    def __queryBondsRateSpreadByEnt__(self, credit_code):
        sql = """
            SELECT TOP 1 all_bp_weight_value * 100 as all_bp_weight_value from base_bonds_interest_rate_spread_enterprise
            where credit_code = %s order by trade_date DESC 
        """
        data = self.absSqlServer.execute_query(sql,credit_code)
        return data


